package com.swing.sky.system.framework.security.utils;

import com.swing.sky.system.framework.security.service.UserDetailsImp;
import com.swing.sky.system.module.domain.SysUserDO;
import org.springframework.security.core.context.SecurityContextHolder;

public class UserDetailsUtil {

    public static SysUserDO getUserDO() {
        UserDetailsImp userDetails = (UserDetailsImp) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        return userDetails.getUserDO();
    }

    public static String getUsername() {
        return getUserDO().getUsername();
    }

    public static Long getUserId() {
        return getUserDO().getId();
    }
}
